package fti.uksw.ruang.dialog;

import android.app.AlertDialog;
import android.app.Dialog;
//import android.app.DialogFragment;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;

public class YesNoDialog extends DialogFragment {

	static String dialogTitle;
	static String dialogMessage;
	static Context context;
	
	public YesNoDialogListener mListener;
	
	public interface YesNoDialogListener{
		public void yesListener();
		public void noListener();
	}
	
	public void setYesNoDialogListener(YesNoDialogListener listener){
		mListener = listener;
	}

	public static YesNoDialog newInstance(Context mContext, String mDialogTitle, String mDialogMsg) {
		context = mContext;
		dialogTitle = mDialogTitle;
		dialogMessage = mDialogMsg;
		YesNoDialog dialog = new YesNoDialog();

		Bundle args = new Bundle();
		args.putString("title", dialogTitle);
		args.putString("message", dialogMessage);
		dialog.setArguments(args);
		return dialog;
	}

	@Override
	public Dialog onCreateDialog(Bundle savedInstanceState) {
//		String title = getArguments().getString("title");
		return new AlertDialog.Builder(getActivity()).setTitle(dialogTitle)
				.setMessage(dialogMessage)
				.setNegativeButton("No", new OnClickListener() {

					@Override
					public void onClick(DialogInterface dialog, int which) {
						mListener.noListener();
					}
				}).setPositiveButton("Yes", new OnClickListener() {

					@Override
					public void onClick(DialogInterface dialog, int which) {
						mListener.yesListener();
					}
				})
				.create();
	}

}
